<template>
    <div class="background">
        <div class="login-container">
            <h2>注册</h2>
            <input type="text" v-model="username" placeholder="用户名" />
            <input type="password" v-model="oldpassword" placeholder="请输入密码" />
            <input type="password" v-model="newpassword" placeholder="请再次输入密码" />
            <button @click="login">注册</button>
        </div>
    </div>
</template>

<script>

    export default{
        // 返回对应变量
        data(){
            return {
                username:"",
                oldpassword:"",
                newpassword:""
            }
        },

        // 触发事件
        methods:{
            login(){
                // this.$axios
                this.$axios.post("http://localhost:8080/api/user/register", {  
                username: this.username,  
                oldpassword: this.oldpassword,  
                newpassword: this.newpassword,
            })
            .then(res => {  
                console.log(res.data);  
            })  
            .catch(error => {  
                console.error("请求失败:", error);    
            }); 
            }
        },

    }

</script>